home *** CD-ROM | disk | FTP | other *** search
- Path: news.cencom.net!ns!tanp
- From: tanp@ns (Bill Wendling)
- Newsgroups: comp.lang.c
- Subject: Re: What the Exon is THIS?!
- Date: 17 Jan 1996 05:54:29 GMT
- Organization: Cen-Com Internet
- Message-ID: <4di2ul$j77@news.cencom.net>
- References: <4d6rgh$rfu@abel.cc.sunysb.edu> <4dc2o1$ea8@hammy.lonestar.org>
- NNTP-Posting-Host: ns.cencom.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Gordon Burditt inexplicably wrote:
- } > int (*p)[3] is?????
-
- } A pointer to an array of 3 integers.
-
- } >(*p)[0] = 3; for e.g, but when I print the value using:
- } >
- } > printf("%d",(*p)[0]) I get a core dump!
-
- } You can store into it, but when you try to access it, it core dumps?
- } This is rather strange.
-
- Not really, p is only a pointer to an array of 3 integers. No array
- of 3 integers has been assigned to p. The assignment (*p)[0] = 3; seems
- to not have anyplace to put 3. The correct version of this program is:
-
- main()
- {
- int (*p)[3];
- int array[3];
-
- p = &array;
- (*p)[0] = 3;
-
- print("%d\n", (*p)[0]);
- }
-
- This prints out the correct value of 3.
-
-
- --
- Bill Wendling | "Pinky, are you thinking what I'm thinking?"
- tanp@ns.cencom.net | "I think so, Brain, but burlap chafes me so."
- "Boom Shanka" | Finger me for my Geek Code...NOW!
-